{%  extends "admin/common/admin_base.html" %}
{% block title -%}
    首页管理
{%- endblock %}
{% block page_title -%}首页管理{% endblock %}
{% block page_btn_name -%}后台首页{% endblock %}
{% block content -%}
<section class="content">
    <div class="alert alert-danger">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
        <p>欢迎来到后台</p>
    </div>
    <div class="row">
        <div class="col-lg-6 col-sm-6 col-xs-12">

        <div class="box box-primary">
            <div class="box-header">
                <h3 class="box-title">系统信息</h3>
            </div>
            <div class="box-body no-padding">
                <table class="table table-hover">
                    {% for v in sysinfo %}
                    <tr>
                        <td>{{ v }}：{{ sysinfo[v]|default('未获取到系统信息',True) }}</td>
                    </tr>
                    {% endfor %}
                </table>
            </div>
        </div>

        <div class="box box-primary">
            <div class="box-header with-border">
                <h3 class="box-title">服务器内存（<b>{{ svemm[0]}}G</b>）使用情况</h3>
            </div>
            <div class="box-body">
                <canvas id="myChart" height="50%"></canvas>
            </div>
        </div>

        </div>

        <div class="col-lg-6 col-sm-6 col-xs-12">
            <div class="box box-primary">
                <div class="box-header">
                    <h3 class="box-title">最新登录</h3>
                </div>
                <div class="box-body no-padding">
                    <table class="table table-hover">
                        <tr>
                            <th>ip</th>
                            <th>用户名称</th>
                            <th>最后一次登录时间</th>
                        </tr>
                        {% for v in logins %}
                        <tr>
                            <td><span class="label label-success">{{ v.ip }}</span></td>
                            <td>{{ v.admin.admin_name }}</td>
                            <td>{{ v.create_time }}</td>
                        </tr>
                        {% endfor %}
                    </table>
                </div>
            </div>
        </div>

        <div class="col-lg-6 col-sm-6 col-xs-12">
               <!-- Chat box -->
          <div class="box box-success">
            <div class="box-header">
              <i class="fa fa-comments-o"></i>

              <h3 class="box-title">最新文章</h3>
            </div>
            <div class="box-body chat" id="chat-box">
              <!-- chat item -->
                {% for v in posts_new -%}
                  <div class="item">
                    <img src="{{ no_img(v.feature_img.split(',')[0]) }}" alt="{{ v.post_title }}" class="online">

                    <p class="message">
                      <a href="#" class="name">
                        <small class="text-muted pull-right"><i class="fa fa-clock-o"></i> {{ v.create_time }}</small>
                       {{ v.admin.admin_name }}
                      </a>
                      {{ v.post_title }}
                    </p>
                  </div>
                {%- endfor %}
            </div>
          </div>
        </div>
    </div>
</section>
    <script>
    $(function () {
        var config = {
			type: 'pie',
			data: {
				datasets: [{
					data: [
						{{ (svemm[3]/svemm[0]*100)|int }},
						{{ (svemm[4]/svemm[0]*100)|int }},
					],
					backgroundColor: [
						"#dd4b39",
                        "#3c8dbc",
					],
					label: 'Dataset 1'
				}],
				labels: [
					'已使用内存 '+ {{ svemm[3] }} +"G",
                    '可用内存 '+ {{ svemm[4] }} +"G",
				]
			},
			options: {
				responsive: true
			}
		};
        var ctx = document.getElementById('myChart').getContext('2d');
        new Chart(ctx, config)
    })
    </script>
{% endblock %}
